package thread;


class Test{
    public int value = 0;
}

public class Demo10 {
    private static  boolean isFinished = false;

    public static void main(String[] args) throws InterruptedException{
        //放到这里
        //boolean isFinished = false;

        Test test = new Test();

        Thread t = new Thread(()->{
           while (!isFinished){
               System.out.println("hello thread");
               try{
                   Thread.sleep(1000);
               }catch (InterruptedException e){
                   throw new RuntimeException(e);
               }
           }
            System.out.println("thread end");
            //System.out.println(test.value);
            //test.value++;
        });
        t.start();

        Thread.sleep(1000);
        isFinished = true;


    }
}
